﻿namespace Sidvall.WorkItemManager.UI.Entities
{
	public sealed partial class MonitorContext
	{
		#region Deserialize

		[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")]
		public static MonitorContext Deserialize(string value)
		{
			MonitorContext item;
			Sidvall.WorkItemManager.Net.Services.V1.MonitorContext data;

			data = null;
			try
			{
				if (!string.IsNullOrWhiteSpace(value))
					data = Sidvall.Serialization.SerializerManager.Current.Deserialize<Sidvall.WorkItemManager.Net.Services.V1.MonitorContext>(value);
			}
			catch
			{
				data = null;
			}
			if (data == null)
			{
				data = new Sidvall.WorkItemManager.Net.Services.V1.MonitorContext()
				{
					IsBodyHtml = false,
				};
			}
			item = new MonitorContext();
			item.Import(data, Sidvall.Data.CopySettings.FullCopyAll(Sidvall.Data.DataRowContextOption.None, Sidvall.Data.DataRowState.Unchanged));

			return item;
		}

		#endregion
		#region Serialize

		public static string Serialize(MonitorContext item)
		{
			Sidvall.WorkItemManager.Net.Services.V1.MonitorContext data;

			data = new Net.Services.V1.MonitorContext();
			data.Import(item, Sidvall.Data.CopySettings.FullCopyAll(Sidvall.Data.DataRowContextOption.None, null));

			return Sidvall.Serialization.SerializerManager.Current.SerializeObject(data);
		}

		#endregion
	}
}